from django.db import models
from reportservice.helpers import TableModel
import uuid


class RepModel(TableModel):
    # UUID 字段
    uuid = models.CharField(max_length=64,
                            default=uuid.uuid4, unique=True)
    # path: model_docs/:uuid
    name = models.CharField(max_length=64)
    path = models.CharField(max_length=64)
    company = models.CharField(max_length=64)

    class Meta:
        db_table = 'xm_report_model'

    def __str__(self) -> str:
        return super().__str__()


class Report(TableModel):
    report_code = models.CharField(max_length=32)  # 报告编号
    # UUID 字段
    uuid = models.UUIDField(
        default=uuid.uuid4, editable=False, unique=True)
    # 完成时间（可以手动设置）
    completed_at = models.DateTimeField(null=True, blank=True)
    # 文件路径
    report_path = models.CharField(max_length=255)

    model_id = models.IntegerField()
    # 电子签订单号
    digital_sign_order_no = models.CharField(max_length=64, null=True)
    digital_sign_biz_id = models.CharField(max_length=64, null=True)
    is_backup = models.BooleanField('是否备份',default=False)

    class Meta:
        db_table = 'xm_report'

    def __str__(self):
        return f"Report {self.id} uuid {self.uuid}"
